import { Game } from "phaser";
import Test from "./scenes/Test";
import QGamePlugin from "./QGameComponent/QGamePlugin";

// More information about config: https://newdocs.phaser.io/docs/3.70.0/Phaser.Types.Core.GameConfig
const config = {
    type: Phaser.AUTO,
    parent: "phaser-container",
    // width: 1920,
    // height: 1080,
    // width: 1280,
    // height: 720,
    backgroundColor: "#222222",
    // pixelArt: true,
    // roundPixel: false,
    antialias: true,
    max: {
        // width: 1920,
        // height: 1080,
        // width:960,
        // height:540,
        // width: 1280,
        // height: 720,
    },
    scale: {
        mode: Phaser.Scale.FIT,
        autoCenter: Phaser.Scale.CENTER_BOTH,
        parent: "phaser-container",
        resolution: window.devicePixelRatio || 1,
        // width: "100%",
        // height: "100%",
        // width: 1024,
        // height: 768,
    },
    physics: {
        default: "matter",
        matter: {
            gravity: { y: 0, x: 0 },
            enableSleep: false,
            debug: false,
        },
    },
    // fps: {
    //     limit: 120,
    // },
    input: {
        activePointers: 2, // 启用多点触摸支持
    },
    // 这是加场景
    scene: [Test],
    plugins: {
        scene: [
            {
                key: "QGamePlugin",
                plugin: QGamePlugin,
                mapping: "qGame",
            },
        ],
    },
};

window.game = new Game(config);

// window.game.scale.on("resize", (gameSize) => {
//     // // 游戏尺寸改变时的回调
//     // if (this.cameras.main) {
//     //     this.cameras.main.setViewport(0, 0, gameSize.width, gameSize.height);
//     // }
//     // this.scale.resize(width, height);
//     // console.log("游戏尺寸改变", gameSize);
// });
